package com.thiswhyme.seata.storage.controller;

import com.thiswhyme.common.response.ResponseVo;
import com.thiswhyme.seata.storage.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: thiswhyme
 * @date: 2020/9/4
 */
@RestController
@RequestMapping("/storage/")
public class ProductController {

    @Autowired
    private ProductService productService;

    @PostMapping("reduceStock")
    public ResponseVo<Boolean> reduceStock(@RequestParam Long productId, @RequestParam Integer requiredAmount) {
        return ResponseVo.success(productService.reduceStock(productId, requiredAmount));
    }
}
